package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@Api(tags = "店铺状态相关接口")
@RestController
@RequestMapping("/admin/shop")
@Slf4j
public class ShopController {

    @Autowired
    RedisTemplate redisTemplate;

    private static final String SHOP_STATUS = "SHOP_STATUS";

    /**
     * 管理端-获取店铺装填
     * @return
     */
    @ApiOperation("管理端-获取店铺状态")
    @GetMapping("/status")
    public Result getStatus(){
        return Result.success(redisTemplate.opsForValue().get(SHOP_STATUS));
    }

    /**
     * 管理端-设置店铺状态
     * @param status
     * @return
     */
    @ApiOperation("管理端-设置店铺状态")
    @PutMapping("/{status}")
    public Result setStatus(@PathVariable int status){
        redisTemplate.opsForValue().set(SHOP_STATUS,status);
        return Result.success();
    }


}
